package com.maven.front.service.teacher;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.maven.front.bean.EduTeacher;
import com.maven.front.bean.Result;
import com.maven.front.mapper.EduTeacherMapper;
import com.maven.front.pagehelper.PagehelperBean;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;


@Service
public class EduTeacherService {

    @Resource
    private EduTeacherMapper eduTeacherMapper;

    public Result list(EduTeacher eduTeacher){
        List<EduTeacher>list=this.eduTeacherMapper.select(eduTeacher);
        //判断集合是否为空
        if(CollectionUtils.isEmpty(list)){
            return new Result(10001,"查询失败");
        }else{
            return new Result(200,"成功",list);
        }
    }

      public int save(EduTeacher eduTeacher){
          //状态:0正常1删除
         eduTeacher.setStatus((byte)0);
          //添加时间
          eduTeacher.setCreateTime(new Date());
          eduTeacher.setUpdateTime(new Date());
          return eduTeacherMapper.insertSelective(eduTeacher);

      }

      public int update(EduTeacher eduTeacher){
          eduTeacher.setUpdateTime(new Date());
        return this.eduTeacherMapper.updateByPrimaryKeySelective(eduTeacher);
      }


      public int delete(int id){
        return this.eduTeacherMapper.deleteByPrimaryKey(id);
      }


      public EduTeacher getById(int id){
        return eduTeacherMapper.selectByPrimaryKey(id);
      }

    public Result list() {
        return null;
    }


}
